//
//  Questions.m
//  06-超级猜图
//
//  Created by wangneihan on 15/12/14.
//  Copyright © 2015年 wangneihan. All rights reserved.
//

#import "Questions.h"

@implementation Questions

-(instancetype)initWithDic:(NSDictionary *) dic{
    if (self = [self init]) {
        self.answer = dic[@"answer"];
        self.icon = dic[@"icon"];
        self.title = dic[@"title"];
        self.options = dic[@"options"];
    }
    return self;
}

+(instancetype)questionsInitWithDic:(NSDictionary *) dic{
    return [[self alloc]initWithDic:dic];
}

+(NSArray *)loadQuestions{
    
    NSBundle *bundle = [NSBundle mainBundle];
    
    NSString *path = [bundle pathForResource:@"questions" ofType:@"plist"];
    
    NSArray *tempArray = [NSArray arrayWithContentsOfFile:path];
    
    NSMutableArray * resultArray = [[NSMutableArray alloc]init];
    
    for (int i =0; i < tempArray.count ; i++) {
        Questions *ques = [Questions questionsInitWithDic:tempArray[i]];
        [resultArray addObject:ques];
    }
    
    return resultArray;
    
}

@end
